home *** CD-ROM | disk | FTP | other *** search
/ Packard Bell - Internet on a CD / internet on a cd.cdr / Internet / sites / Clementine_NASA / image.hqx / Image folder / Macros / Measurement Macros < prev    next >
Encoding:
Text File  |  1991-08-01  |  4.2 KB  |  205 lines

  1. macro 'Display Calibration Table';
  2. {
  3. Stores 0-255(all possible raw pixel values) in the Area column
  4. and the 256 corresponding calibrated values in the Mean column.
  5. Max Measurements must be set to 256 or greater. Use the Export
  6. command to export the calibration table to a text file. The two
  7. columns will be identical if the image has not been calibrated
  8. using the Calibrate command.
  9. }
  10. var
  11.   i:integer;
  12.   v:real;
  13. begin
  14.   SetCounter(256); {SetCounter new in V1.41}
  15.   for i:=0 to 255 do begin
  16.     rArea[i+1]:=i;
  17.     rMean[i+1]:=cvalue(i);
  18.   end;
  19.   ShowResults;
  20.   Export;
  21. end;
  22.  
  23.  
  24. macro 'Measure and draw line [L]';
  25. var
  26.   x1,x2,y1,y2,width:integer;
  27. begin
  28.   GetLine(x1,y1,x2,y2,width);
  29.   if x1<0 then begin
  30.     PutMessage('This macro requires a line selection.');
  31.     exit;
  32.   end;
  33.   Measure;
  34.   Fill;
  35.   KillRoi;
  36. end;
  37.  
  38.  
  39. macro 'Measure All';
  40. {Measures all currently open images using the current selection. There is}
  41. {an implied "Select All" if the active image doesn't have a selection.}
  42. var
  43.   i,left,top,width,height:integer;
  44. begin
  45.   ResetCounters;
  46.   for i:=1 to nPics do begin
  47.     SelectPic(i);
  48.     RestoreROI;
  49.     Measure;
  50.   end;
  51. end;
  52.  
  53.  
  54. macro 'Measure All from Disk';
  55. {
  56. Reads from disk and measures a set of images too large to simultaneously
  57. fit in memory. The image names names must be in the form '01', '02', etc.
  58. Before starting, open and outline the first image('01').
  59. }
  60. var
  61.   i,width,height:integer;
  62. begin
  63.   GetPicSize(width,height);
  64.   if width=0 then begin
  65.     PutMessage('Before running this macro, open and outline the first image("01") in the series.');
  66.     exit;
  67.   end;
  68.   ResetCounters;
  69.   Measure;
  70.   close;
  71.   for i:=2 to 1000 do begin
  72.     open(i:2);
  73.     RestoreROI;
  74.     Measure;
  75.     close;
  76.   end;
  77. end;
  78.  
  79.  
  80. macro 'Paste Results [P]'
  81. {Use the Measure command, the ruler tool, or the pointing tool to}
  82. {make up to about 10 measurements, then use this macro to paste}
  83. {the results into the upper left corner of the window.}
  84. begin
  85.   SetFont('Monaco');
  86.   SetFontSize(9);
  87.   SetText('Plain; Align Left');
  88.   SetOption; {Copy headings}
  89.   CopyResults;
  90.   MakeRoi(-10,0,250,150);
  91.   Paste;
  92.   KillRoi;
  93.   ResetCounters;
  94. end;
  95.  
  96.  
  97. macro 'Measure Redirected and Label'
  98. begin
  99.   Redirect(true);
  100.   Measure;
  101.   Redirect(false);
  102.   MarkSelection;
  103.   RestoreRoi;
  104. end;
  105.  
  106.  
  107. macro 'Reset Analysis Options';
  108. {Resets the Options dialog box in the Analyze menu to the default settings.}
  109. begin
  110.   MeasureArea(true);
  111.   MeasureDensity(true);
  112.   MeasureStandardDeviation(false);
  113.   MeasureXY(false);
  114.   MeasureMode(false);
  115.   MeasurePerimeter(false);
  116.   MeasureMajorAxis(false);
  117.   MeasureMinorAxis(false);
  118.   MeasureAngle(false);
  119.   MeasureIntegratedDensity(false);
  120.   Redirect(false);
  121.   LabelParticles(true);
  122.   OutlineParticles(false);
  123.   IgnoreParticlesTouchingEdge(false);
  124.   IncludeInteriorHoles(false);
  125.   WandAutoMeasure(false);
  126.   AdjustAreas(false);
  127.   SetParticleSize(1,999999);
  128.   SetPrecision(2);
  129. end;
  130.  
  131.  
  132. macro 'Set Threshold';
  133. var
  134.   lower,upper:integer;
  135. begin
  136.   lower:=GetNumber('Lower:',1);
  137.   upper:=GetNumber('Upper:',254);
  138.   SetDensitySlice(lower,upper);
  139. end;
  140.  
  141.  
  142. macro 'Measure Accumulated Perimeter[A]';
  143. {
  144. Measures perimeter and computes accumulated perimeter,
  145. storing it in the Major Axis column.
  146. }
  147. var
  148.   i:integer;
  149.   TotalPerimeter:real;
  150. begin
  151.   MeasurePerimter(true);
  152.   SetMajorLabel('Total');
  153.   Measure;
  154.   TotalPerimeter:=0;
  155.   for i:=1 to rCount do TotalPerimeter:=TotalPerimeter+rLength[i];
  156.   rMajor[rCount]:=TotalPerimeter;
  157.   UpdateResults;
  158. end;
  159.  
  160. macro 'Count Black and White Pixels [B]';
  161. {
  162. Counts the number of black and white pixels in the current
  163. selection and stores the counts in the Major and Minor Axis columns.
  164. }
  165. begin
  166.   SetMajorLabel('Black');
  167.   SetMinorLabel('White');
  168.   Measure;
  169.   rMajor[rCount]:=histogram[255];
  170.   rMinor[rCount]:=histogram[0];
  171.   UpdateResults;
  172. end;
  173.  
  174.  
  175. macro 'Compute Average and Total Area [T]';
  176. {
  177. Computes average and accumulated area and stores 
  178. the them in the Major and Minor Axis columns.
  179. }
  180. var
  181.   i:integer;
  182.   TotalArea:real;
  183. begin
  184.   SetMajorLabel('Average');
  185.   SetMinorLabel('Total');
  186.   Measure;
  187.   TotalArea:=0;
  188.   for i:=1 to rCount do TotalArea:=TotalArea+rArea[i];
  189.   rMajor[rCount]:=TotalArea/rCount;;
  190.   rMinor[rCount]:=TotalArea;
  191.   UpdateResults;
  192. end;
  193.  
  194.  
  195. macro 'Measure Circularity [C]';
  196. begin
  197.   SetMajorLabel('Shape');
  198.   Measure;
  199.   rMajor[rCount]:=4*3.14159265*(rArea[rCount]/sqr(rLength[rCount]));
  200.   UpdateResults;
  201. end;
  202.  
  203.  
  204.  
  205.